#ifndef _SPLAY_MAP_H_
#define _SPLAY_MAP_H_

#include "Splay.h"

template<typename V, typename K>
struct PairKeyExtrctor;

template<typename K, typename V, typename Pr = less<K> >
class SplayMap: public SplayTree<K, pair<const K, V>, Pr, PairKeyExtrctor<V, K> > {
public:
	typedef K key_type;
	typedef V data_type;
	typedef SplayTree<K, pair<const K, V>, Pr, PairKeyExtrctor<V, K> > BaseClass;
	data_type& operator[](const key_type& key) {
		typename BaseClass::iterator it = BaseClass::find(key);
		if (it != BaseClass::end()) {
			return it->second;
		}
		data_type dat;
		return BaseClass::insert(make_pair(key, dat)).first->second;
	}
};

#endif